﻿using System;
using System.Web;
using System.Web.Configuration;
using System.Data;

public partial class product_Mask_project_View : System.Web.UI.Page
{
    DBHelper db = new DBHelper(WebConfigurationManager.ConnectionStrings["connString"].ConnectionString);
    public int renum = 0;
    public string HtmlStr = "";
    public string PageHtmlStr1 = "";
    public string PageHtmlStr2 = "";
    public string pb_name = "";
    public string pb_productno = "";
    public string pb_norm = "";
    public string pb_zd1 = "";
    public string pb_suitable = "";
    public string imgfile = "";
    public int pbid = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        pbid = Convert.ToInt32(Request.QueryString["id"]);
        //此处添加检测权限
        GetProductHtml();
        GetPageHtml();
    }
    public void GetProductHtml()
    {
        string sql = "select  * from Production where id=" + pbid + " and IsUsing=1";
        DataTable dt = db.getList(sql);
        foreach (DataRow dr in dt.Rows)
        {
            imgfile = "/static/img/zzz.jpg";
            pb_name = dr["name"].ToString();
            pb_productno = dr["productno"].ToString();
            pb_norm = dr["norm"].ToString();
            pb_zd1 = dr["zd1"].ToString();
            pb_suitable = dr["suitable"].ToString();
            if (dr["imgfile"].ToString() != "" && dr["imgfile"].ToString() != "null" && dr["imgfile"].ToString() != "NULL")
            {
                imgfile = "http://logocatalogue.sanqicn.com/upload/image/product/img/" + dr["imgfile"].ToString();
            }
        }

    }

    public void GetPageHtml()
    {
        string sql = "select id,name from Production where typeid in(select typeid from Production where id=" + pbid + ") order by id";
        DataTable dt = db.getList(sql);
        int i = 0;
        int j = 0;
        int si = 0;
        int xj = 0;
        int sjsj = 0;

        int[] index = new int[dt.Rows.Count];
        foreach (DataRow dr in dt.Rows)
        {
            Random rm = new Random();
            sjsj = rm.Next();
            index[i] = Convert.ToInt32(dr["id"].ToString());
            if (Convert.ToInt32(dr["id"].ToString()) == pbid)
            {
                j = i;
                PageHtmlStr1 += " <li class=\"on\" onclick=\"window.location.href='View.aspx?id=" + dr["id"].ToString() + "&sjsj=" + sjsj + "'\">" + dr["name"].ToString() + "</li>";
            }
            else
            {
                PageHtmlStr1 += " <li onclick=\"window.location.href='View.aspx?id=" + dr["id"].ToString() + "&sjsj=" + sjsj + "'\">" + dr["name"].ToString() + "</li>";
            }
            i++;
        }

        if (j < dt.Rows.Count - 1)
        {
            xj = j + 1;
            PageHtmlStr2 += "<input type=\"button\" onclick=\"window.location.href='View.aspx?id=" + index[xj].ToString() + "&sjsj=" + sjsj + "'\" value=\"下一产品\"/>";
        }
        if (j >= 1)
        {
            si = j - 1;
            PageHtmlStr2 += "<input type=\"button\" onclick=\"window.location.href='View.aspx?id=" + index[si].ToString() + "&sjsj=" + sjsj + "'\" value=\"上一产品\"/>";
        }




    }
}